﻿using System;
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{

    class Parallelshanktwistarills2
    {
        public static void _Parallelshanktwistarills2(Dictionary<string, Object> data)//细柄丝锥
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            //double scale = 1; //放大系数
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            double d = Convert.ToDouble(data["dc"]) * scale;
             double l = Convert.ToDouble(data["oal"]) * scale;
             double l1 = Convert.ToDouble(data["lcf"]) * scale;
            double a = Convert.ToDouble(data["a"]) * scale;
            double czc = Convert.ToDouble(data["czc"]) * scale;

            /*double d = 3.8;
            double l = 55;
            double l1 = 22;
            double  a = 0;
            double czc = 1;*/


            if (d < 3 || d > 30)
            {
                //坐标
                Vector2 v1 = new Vector2(0, 0);
                Vector2 v2 = new Vector2(v1.X + l + 4, v1.Y);
                Vector2 v29 = new Vector2(v1.X + 2, v1.Y);
                Vector2 v3 = new Vector2(v29.X + d / 4.225, v29.Y + d / 2);
                Vector2 v4 = new Vector2(v3.X, v3.Y - d);
                Vector2 v5 = new Vector2 (v29.X+l1/20.11538,v29.Y +d/4.931);
                Vector2 v6 = new Vector2 (v29.X +l1/5.76838,v29.Y -d/3.605);
                Vector2 v8 = new Vector2(v29.X + l1/4.903125, v29.Y + d / 3.37795);
                Vector2 v9 = new Vector2(v29.X + l1 / 3.0348, v29.Y - d / 4.98837);
                Vector2 v10 = new Vector2(v29.X + l1/3.55782, v29.Y - d / 6.04225);
                Vector2 v7 = new Vector2(v29.X + l1 / 2.96317, v29.Y - d / 2.715189);
                Vector2 v11 = new Vector2(v29.X + l1 / 2.309, v29.Y - d / 2.5789);
                Vector2 v12 = new Vector2(v29.X + l1 / 1.71194, v29.Y - d / 3.22556);
                Vector2 v13 = new Vector2(v29.X + l1 / 2.9437, v29.Y + d / 1.9861);
                Vector2 v14 = new Vector2(v29.X + l1 / 1.9216, v29.Y);
                Vector2 v15 = new Vector2(v29.X + l1 / 1.23, v29.Y - d / 2.34426);
                Vector2 v16 = new Vector2(v29.X + l1 / 2.0128, v29.Y + d / 1.9769);
                Vector2 v17 = new Vector2(v29.X + l1 / 1.521, v29.Y);
                Vector2 v18 = new Vector2(v29.X + l1 / 1.62759, v29.Y + d / 2.7857);
                Vector2 v19 = new Vector2(v29.X + l1 / 1.4309, v29.Y);
                Vector2 v20 = new Vector2(v29.X + l1 / 1.1369, v29.Y - d / 1.9678899);
                Vector2 v21 = new Vector2(v29.X + l1 / 1.416, v29.Y + d / 2.0856);
                Vector2 v22 = new Vector2(v29.X + l1 / 1.164378, v29.Y - d / 26.8125);
                Vector2 v23 = new Vector2(v29.X + l1 / 1.19588, v29.Y - d / 2.13432);
                Vector2 v24 = new Vector2(v29.X + l1 / 1.303697, v29.Y + d / 2.052631);
                Vector2 v25 = new Vector2(v29.X + l1 / 1.113555, v29.Y + d / 12.25714);
                Vector2 v26 = new Vector2(v25.X + l1 / 9.9625, v1.Y);
                Vector2 v27 = new Vector2(v29.X + l1 / 1.0031969, v29.Y + d / 10.214285);
                Vector2 v28 = new Vector2(v29.X + l1 / 1.205069, v29.Y + d / 2.033175);
                Vector2 v30 = new Vector2(v29.X + l - (v28.Y -v20.Y )/5, v28.Y);
                Vector2 v31 = new Vector2(v30.X + (v28.Y - v20.Y) / 5, v30.Y - (v28.Y - v20.Y) / 5);
                Vector2 v33 = new Vector2(v30.X, v20.Y);
                Vector2 v32 = new Vector2(v33.X + (v28.Y - v20.Y) / 5, v33.Y + (v28.Y - v20.Y) / 5);

                Vector2 v34 = new Vector2(v2.X + d, v2.Y);
                Vector2 v35 = new Vector2(v34.X - d / 2 - 2, v34.Y);
                Vector2 v36 = new Vector2(v34.X + d / 2 + 2, v34.Y);
                Vector2 v37 = new Vector2(v34.X, v34.Y + d / 2 + 2);
                Vector2 v38 = new Vector2(v34.X, v34.Y - d / 2 - 2);
                Vector2 v39 = fun.Polar(v34, -77 * pi / 180, v30.Y - v1.Y);
                Vector2 v40 = fun.Polar(v34, 31 * pi / 180, v30.Y - v1.Y);
                Vector2 v41 = new Vector2(v34.X, v34.Y + v30.Y - v1.Y);
                Vector2 v42 = new Vector2(v39.X, v39.Y + d / 4.37);
                Vector2 v43 = fun.Polar(v34, -79 * pi / 180, d / 2);
                Vector2 v44 = fun.Polar(v34, 103 * pi / 180, v30.Y - v1.Y);
                Vector2 v45 = fun.Polar(v34, -149 * pi / 180, v30.Y - v1.Y);
                Vector2 v46 = new Vector2(v41.X, v41.Y * -1);
                Vector2 v47 = new Vector2(v44.X, v44.Y - d / 4.37);
                Vector2 v48 = fun.Polar(v34, 101 * pi / 180, d / 2);
                Vector2 v49 = new Vector2(v34.X, v34.Y + d / 2);
                Vector2 v50 = new Vector2(v34.X, v34.Y - d / 2);
                //作图
                Line line1 = new Line(v1, v2);
                line1.Layer = center;
                line1.Linetype = Linetype.DashDot;
                line1.LinetypeScale = 3;
                dxf.AddEntity(line1);

                LwPolyline line2 = new LwPolyline();
                line2.Vertexes.Add(new LwPolylineVertex(v29));
                line2.Vertexes.Add(new LwPolylineVertex(v5));
                line2.Vertexes.Add(new LwPolylineVertex(v3));
                line2.Vertexes.Add(new LwPolylineVertex(v29));
                line2.Vertexes.Add(new LwPolylineVertex(v4));
                line2.Vertexes.Add(new LwPolylineVertex(v6));
                line2.Vertexes[0].Bulge = Math.Tan(-51 * pi / 180 / 4);
                line2.Vertexes[4].Bulge = Math.Tan(43 * pi / 180 / 4);
                fun.PolyFill(dxf, line2, 0.1, contour);

                LwPolyline line3 = new LwPolyline();
                line3.Vertexes.Add(new LwPolylineVertex(v3));
                line3.Vertexes.Add(new LwPolylineVertex(v10));
                line3.Vertexes[0].Bulge = Math.Tan(-32 * pi / 180 / 4);
                fun.PolyFill(dxf, line3, 0.1, contour);

                LwPolyline line4 = new LwPolyline();
                line4.Vertexes.Add(new LwPolylineVertex(v17));
                line4.Vertexes.Add(new LwPolylineVertex(v15));
                line4.Vertexes[0].Bulge = Math.Tan(38 * pi / 180 / 4);
                fun.PolyFill(dxf, line4, 0.1, contour);

                LwPolyline line5 = new LwPolyline();
                line5.Vertexes.Add(new LwPolylineVertex(v22));
                line5.Vertexes.Add(new LwPolylineVertex(v23));
                line5.Vertexes.Add(new LwPolylineVertex(v20));
                line5.Vertexes[0].Bulge = Math.Tan(-47 * pi / 180 / 4);
                line5.Vertexes[1].Bulge = Math.Tan(9 * pi / 180 / 4);
                fun.PolyFill(dxf, line5, 0.1, contour);

                LwPolyline line6 = new LwPolyline();
                line6.Vertexes.Add(new LwPolylineVertex(v25));
                line6.Vertexes.Add(new LwPolylineVertex(v26));
                line6.Vertexes.Add(new LwPolylineVertex(v27));
                line6.Vertexes[0].Bulge = Math.Tan(61 * pi / 180 / 4);
                line6.Vertexes[1].Bulge = Math.Tan(61 * pi / 180 / 4);
                fun.PolyFill(dxf, line6, 0.1, contour);

                LwPolyline line7 = new LwPolyline();
                line7.Vertexes.Add(new LwPolylineVertex(v20));
                line7.Vertexes.Add(new LwPolylineVertex(v33));
                line7.Vertexes.Add(new LwPolylineVertex(v30));
                line7.Vertexes.Add(new LwPolylineVertex(v28));
                fun.PolyFill(dxf, line7, 0.1, contour);

                LwPolyline line8 = new LwPolyline();
                line8.Vertexes.Add(new LwPolylineVertex(v30));
                line8.Vertexes.Add(new LwPolylineVertex(v31));
                line8.Vertexes.Add(new LwPolylineVertex(v32));
                line8.Vertexes.Add(new LwPolylineVertex(v33));
                fun.PolyFill(dxf, line8, 0.1, contour);

                Arc c1 = fun.DrawArc3(v5, v6, v7);
                fun.drawBArc(dxf, c1, 0.1, contour);

                Arc c2 = fun.DrawArc3(v10, v7, v11);
                fun.drawBArc(dxf, c2, 0.1, contour);

                Arc c3 = fun.DrawArc3(v9, v8, v3);
                fun.drawBArc(dxf, c3, 0.1, contour);

                Arc c4 = fun.DrawArc3(v14, v13, v8);
                fun.drawBArc(dxf, c4, 0.1, contour);

                Arc c5 = fun.DrawArc3(v9, v11, v12);
                fun.drawBArc(dxf, c5, 0.1, contour);

                Arc c6 = fun.DrawArc3(v14, v12, v15);
                fun.drawBArc(dxf, c6, 0.1, contour);

                Arc c7 = fun.DrawArc3(v17, v16, v13);
                fun.drawBArc(dxf, c7, 0.1, contour);

                Arc c8 = fun.DrawArc3(v19, v18, v16);
                fun.drawBArc(dxf, c8, 0.1, contour);

                Arc c9 = fun.DrawArc3(v19, v15, v23);
                fun.drawBArc(dxf, c9, 0.1, contour);

                Arc c10 = fun.DrawArc3(v22, v21, v18);
                fun.drawBArc(dxf, c10, 0.1, contour);

                Arc c11 = fun.DrawArc3(v25, v24, v21);
                fun.drawBArc(dxf, c11, 0.1, contour);

                Arc c12 = fun.DrawArc3(v27, v28, v24);
                fun.drawBArc(dxf, c12, 0.1, contour);

                //2
                Line line9 = new Line(v35, v36);
                line9.Layer = center;
                line9.Linetype = Linetype.DashDot;
                line9.LinetypeScale = 3;
                dxf.AddEntity(line9);

                Line line10 = new Line(v37, v38);
                line10.Layer = center;
                line10.Linetype = Linetype.DashDot;
                line10.LinetypeScale = 3;
                dxf.AddEntity(line10);

                LwPolyline line11 = new LwPolyline();
                line11.Vertexes.Add(new LwPolylineVertex(v40));
                line11.Vertexes.Add(new LwPolylineVertex(v42));
                line11.Vertexes.Add(new LwPolylineVertex(v39));
                line11.Vertexes.Add(new LwPolylineVertex(v43));
                line11.Vertexes[0].Bulge = Math.Tan(50 * pi / 180 / 4);
                fun.PolyFill(dxf, line11, 0.1, contour);

                LwPolyline line12 = new LwPolyline();
                line12.Vertexes.Add(new LwPolylineVertex(v45));
                line12.Vertexes.Add(new LwPolylineVertex(v47));
                line12.Vertexes.Add(new LwPolylineVertex(v44));
                line12.Vertexes.Add(new LwPolylineVertex(v48));
                line12.Vertexes[0].Bulge = Math.Tan(50 * pi / 180 / 4);
                fun.PolyFill(dxf, line12, 0.1, contour);

                LwPolyline line13 = new LwPolyline();
                line13.Vertexes.Add(new LwPolylineVertex(v42));
                line13.Vertexes.Add(new LwPolylineVertex(v47));
                line13.Vertexes[0].Bulge = Math.Tan(19 * pi / 180 / 4);
                fun.PolyFill(dxf, line13, 0.1, contour);

                LwPolyline line14 = new LwPolyline();
                line14.Vertexes.Add(new LwPolylineVertex(v49));
                line14.Vertexes.Add(new LwPolylineVertex(v41));
                fun.PolyFill(dxf, line14, 0.1, contour);

                LwPolyline line15 = new LwPolyline();
                line15.Vertexes.Add(new LwPolylineVertex(v46));
                line15.Vertexes.Add(new LwPolylineVertex(v50));
                fun.PolyFill(dxf, line15, 0.1, contour);

                Arc c13 = fun.DrawArc3(v44, v45, v46);
                fun.drawBArc(dxf, c13, 0.1, contour);

                Arc c14 = fun.DrawArc3(v39, v40, v41);
                fun.drawBArc(dxf, c14, 0.1, contour);

                fun.drawcircle(dxf, v34, d / 2, 0.1, contour);

                //标注

                double height = 5;
                double arrowsize = 1;
                double exline = 2;




                fun.dimrot1(dxf, v3, v4, 90, d, 1, height, arrowsize, exline, "d=" + d/scale , "", "");

                fun.dimrot1(dxf, v29, v26, 180, d * 3, 1, height, arrowsize, exline, "l1=" + l1/scale , "", "");

                fun.dimrot1(dxf, v29, v32, 180, d * 5, 1, height, arrowsize, exline, "l=" + l / scale, "", "");



            }
            else
            {
                if (a == 0)
                {
                    double t = 2.12;
                    double l2 = 6;
                    double r = 0.2;
                    if (d >= 3 && d < 3.75)
                    {
                        t = 2.12;
                        l2 = 6;
                    }
                    if (d >= 3.75 && d < 4.75)
                    {
                        t = 2.65;
                        l2 = 7;
                    }
                    if (d >= 4.75 && d < 6)
                    {
                        t = 3.35;
                        l2 = 8;
                    }
                    if (d >= 6 && d < 7.5)
                    {
                        t = 4.25;
                        l2 = 9;
                    }
                    if (d >= 7.5 && d < 9.5)
                    {
                        t = 5.3;
                        l2 = 10;
                    }
                    if (d >= 9.5 && d < 11.8)
                    {
                        t = 6.7;
                        l2 = 11.5;
                    }
                    if (d >= 11.8 && d < 15)
                    {
                        t = 8.5;
                        l2 = 13;
                    }
                    if (d >= 15 && d < 19)
                    {
                        t = 10.6;
                        l2 = 15;
                    }
                    if (d >= 19 && d < 23.6)
                    {
                        t = 13.2;
                        l2 = 17;
                    }
                    if (d >= 23.6 && d <= 30)
                    {
                        t = 17;
                        l2 = 20;
                    }
                    if (d >= 3 && d <6)
                    {
                        r = 0.2;
                    }
                    if (d >= 6 && d < 9.5)
                    {
                        r = 0.3;
                    }
                    if (d >= 9.5 && d < 19)
                    {
                        r = 0.3;
                    }
                    if (d >= 19 && d <= 30)
                    {
                        r = 0.4;
                    }
                    Vector2 a1 = new Vector2(0, 0);
                    Vector2 a2 = new Vector2(a1.X + l + 4, a1.Y);
                    Vector2 a29 = new Vector2(a1.X + 2, a1.Y);
                    Vector2 a3 = new Vector2(a29.X + d / 4.225, a29.Y + d / 2);
                    Vector2 a4 = new Vector2(a3.X, a3.Y - d);
                    Vector2 a5 = new Vector2(a29.X + l1 / 20.11538, a29.Y + d / 4.931);
                    Vector2 a6 = new Vector2(a29.X + l1 / 5.76838, a29.Y - d / 3.605);
                    Vector2 a8 = new Vector2(a29.X + l1 / 4.903125, a29.Y + d / 3.37795);
                    Vector2 a9 = new Vector2(a29.X + l1 / 3.0348, a29.Y - d / 4.98837);
                    Vector2 a10 = new Vector2(a29.X + l1 / 3.55782, a29.Y - d / 6.04225);
                    Vector2 a7 = new Vector2(a29.X + l1 / 2.96317, a29.Y - d / 2.715189);
                    Vector2 a11 = new Vector2(a29.X + l1 / 2.309, a29.Y - d / 2.5789);
                    Vector2 a12 = new Vector2(a29.X + l1 / 1.71194, a29.Y - d / 3.22556);
                    Vector2 a13 = new Vector2(a29.X + l1 / 2.9437, a29.Y + d / 1.9861);
                    Vector2 a14 = new Vector2(a29.X + l1 / 1.9216, a29.Y);
                    Vector2 a15 = new Vector2(a29.X + l1 / 1.23, a29.Y - d / 2.34426);
                    Vector2 a16 = new Vector2(a29.X + l1 / 2.0128, a29.Y + d / 1.9769);
                    Vector2 a17 = new Vector2(a29.X + l1 / 1.521, a29.Y);
                    Vector2 a18 = new Vector2(a29.X + l1 / 1.62759, a29.Y + d / 2.7857);
                    Vector2 a19 = new Vector2(a29.X + l1 / 1.4309, a29.Y);
                    Vector2 a20 = new Vector2(a29.X + l1 / 1.1369, a29.Y - d / 1.9678899);
                    Vector2 a21 = new Vector2(a29.X + l1 / 1.416, a29.Y + d / 2.0856);
                    Vector2 a22 = new Vector2(a29.X + l1 / 1.164378, a29.Y - d / 26.8125);
                    Vector2 a23 = new Vector2(a29.X + l1 / 1.19588, a29.Y - d / 2.13432);
                    Vector2 a24 = new Vector2(a29.X + l1 / 1.303697, a29.Y + d / 2.052631);
                    Vector2 a25 = new Vector2(a29.X + l1 / 1.113555, a29.Y + d / 12.25714);
                    Vector2 a26 = new Vector2(a25.X + l1 / 9.9625, a1.Y);
                    Vector2 a27 = new Vector2(a29.X + l1 / 1.0031969, a29.Y + d / 10.214285);
                    Vector2 a28 = new Vector2(a29.X + l1 / 1.205069, a29.Y + d / 2.033175);
                    Vector2 a30 = new Vector2(a29.X + l - l2, a28.Y);
                    Vector2 a31 = new Vector2(a30.X, a30.Y -(a30.Y-a20.Y)/2+t/2);
                    Vector2 a32 = new Vector2(a30.X + l2, a31.Y);
                    Vector2 a33 = new Vector2(a30.X, a20.Y);
                    Vector2 a34 = new Vector2(a32.X, a31.Y - t);
                    Vector2 a35 = new Vector2(a33.X, a34.Y);
                    //3
                    Line line16 = new Line(a1, a2);
                    line16.Layer = center;
                    line16.Linetype = Linetype.DashDot;
                    line16.LinetypeScale = 3;
                    dxf.AddEntity(line16);

                    LwPolyline line17 = new LwPolyline();
                    line17.Vertexes.Add(new LwPolylineVertex(a29));
                    line17.Vertexes.Add(new LwPolylineVertex(a5));
                    line17.Vertexes.Add(new LwPolylineVertex(a3));
                    line17.Vertexes.Add(new LwPolylineVertex(a29));
                    line17.Vertexes.Add(new LwPolylineVertex(a4));
                    line17.Vertexes.Add(new LwPolylineVertex(a6));
                    line17.Vertexes[0].Bulge = Math.Tan(-51 * pi / 180 / 4);
                    line17.Vertexes[4].Bulge = Math.Tan(43 * pi / 180 / 4);
                    fun.PolyFill(dxf, line17, 0.1, contour);

                    LwPolyline line18 = new LwPolyline();
                    line18.Vertexes.Add(new LwPolylineVertex(a3));
                    line18.Vertexes.Add(new LwPolylineVertex(a10));
                    line18.Vertexes[0].Bulge = Math.Tan(-32 * pi / 180 / 4);
                    fun.PolyFill(dxf, line18, 0.1, contour);

                    LwPolyline line19 = new LwPolyline();
                    line19.Vertexes.Add(new LwPolylineVertex(a17));
                    line19.Vertexes.Add(new LwPolylineVertex(a15));
                    line19.Vertexes[0].Bulge = Math.Tan(38 * pi / 180 / 4);
                    fun.PolyFill(dxf, line19, 0.1, contour);

                    LwPolyline line20 = new LwPolyline();
                    line20.Vertexes.Add(new LwPolylineVertex(a22));
                    line20.Vertexes.Add(new LwPolylineVertex(a23));
                    line20.Vertexes.Add(new LwPolylineVertex(a20));
                    line20.Vertexes[0].Bulge = Math.Tan(-47 * pi / 180 / 4);
                    line20.Vertexes[1].Bulge = Math.Tan(9 * pi / 180 / 4);
                    fun.PolyFill(dxf, line20, 0.1, contour);

                    LwPolyline line21 = new LwPolyline();
                    line21.Vertexes.Add(new LwPolylineVertex(a25));
                    line21.Vertexes.Add(new LwPolylineVertex(a26));
                    line21.Vertexes.Add(new LwPolylineVertex(a27));
                    line21.Vertexes[0].Bulge = Math.Tan(61 * pi / 180 / 4);
                    line21.Vertexes[1].Bulge = Math.Tan(61 * pi / 180 / 4);
                    fun.PolyFill(dxf, line21, 0.1, contour);

                    LwPolyline line22 = new LwPolyline();
                    line22.Vertexes.Add(new LwPolylineVertex(a20));
                    line22.Vertexes.Add(new LwPolylineVertex(a33));
                    line22.Vertexes.Add(new LwPolylineVertex(a35));
                    line22.Vertexes.Add(new LwPolylineVertex(a34));
                    line22.Vertexes.Add(new LwPolylineVertex(a32));
                    line22.Vertexes.Add(new LwPolylineVertex(a31));
                    line22.Vertexes.Add(new LwPolylineVertex(a30));
                    line22.Vertexes.Add(new LwPolylineVertex(a28));

                    var arc1 = Pus.Fillet4LwPline(line22, 2, r);
                    var arc2 = Pus.Fillet4LwPline(arc1, 6, r);
                    fun.PolyFill(dxf, arc2, 0.1, contour);

                    Arc c15 = fun.DrawArc3(a5, a6, a7);
                    fun.drawBArc(dxf, c15, 0.1, contour);

                    Arc c16 = fun.DrawArc3(a10, a7, a11);
                    fun.drawBArc(dxf, c16, 0.1, contour);

                    Arc c17 = fun.DrawArc3(a9, a8, a3);
                    fun.drawBArc(dxf, c17, 0.1, contour);

                    Arc c18 = fun.DrawArc3(a14, a13, a8);
                    fun.drawBArc(dxf, c18, 0.1, contour);

                    Arc c19 = fun.DrawArc3(a9, a11, a12);
                    fun.drawBArc(dxf, c19, 0.1, contour);

                    Arc c20 = fun.DrawArc3(a14, a12, a15);
                    fun.drawBArc(dxf, c20, 0.1, contour);

                    Arc c21 = fun.DrawArc3(a17, a16, a13);
                    fun.drawBArc(dxf, c21, 0.1, contour);

                    Arc c22 = fun.DrawArc3(a19, a18, a16);
                    fun.drawBArc(dxf, c22, 0.1, contour);

                    Arc c23 = fun.DrawArc3(a19, a15, a23);
                    fun.drawBArc(dxf, c23, 0.1, contour);

                    Arc c24 = fun.DrawArc3(a22, a21, a18);
                    fun.drawBArc(dxf, c24, 0.1, contour);

                    Arc c25 = fun.DrawArc3(a25, a24, a21);
                    fun.drawBArc(dxf, c25, 0.1, contour);

                    Arc c26 = fun.DrawArc3(a27, a28, a24);
                    fun.drawBArc(dxf, c26, 0.1, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;




                    fun.dimrot1(dxf, a3, a4, 90, d, 1, height, arrowsize, exline, "d=" + d/scale , "", "");

                    fun.dimrot1(dxf, a29, a26, 180, d * 3, 1, height, arrowsize, exline, "l1=" + l1/scale , "", "");

                    fun.dimrot1(dxf, a29, a34, 180, d * 5, 1, height, arrowsize, exline, "l=" + l/scale , "", "");

                }
                if (a == 1)
                {
                    double db = 0;
                    double ds = 0;
                    double tg = 0;
                    double S = 0;
                    double L = 0;
                    double a1 = 2.3;
                    double L1 = 18;
                    double L2 = 15;
                    if (czc == 1)
                    {
                        db = 12.065 * scale;
                        ds = 9.4 * scale;
                        tg = 0.04988;
                        S = 4.5;
                        L = 66.65;
                    }
                    if (czc == 2)
                    {
                        db = 17.78 * scale;
                        ds = 14.6 * scale;
                        tg = 0.04995;
                        S = 6;
                        L = 81;
                    }
                    if (czc == 3)
                    {
                        db = 23.825 * scale;
                        ds = 19.8 * scale;
                        tg = 0.05020;
                        S = 6;
                        L = 100;
                    }
                    if (czc == 4)
                    {
                        db = 31.267 * scale;
                        ds = 25.9 * scale;
                        tg = 0.05194;
                        S = 9.5;
                        L = 127;
                    }
                    if (czc == 5)
                    {
                        db = 44.399 * scale;
                        ds = 37.6 * scale;
                        tg = 0.05263;
                        S = 11;
                        L = 160.5;
                    }
                    if (d >= 3 && d < 3.75)
                    {
                        a1 = 2.3;
                        L1 = 18;
                        L2 = 15;
                    }
                    if (d >= 3.75 && d < 4.75)
                    {
                        a1 = 2.9;
                        L1 = 20;
                        L2 = 16;
                    }
                    if (d >= 4.75 && d < 6)
                    {
                        a1 = 3.6;
                        L1 = 22;
                        L2 = 17;
                    }
                    if (d >= 6 && d < 7.5)
                    {
                        a1 = 4.5;
                        L1 = 25;
                        L2 = 19;
                    }
                    if (d >= 7.5 && d < 9.5)
                    {
                        a1 = 5.6;
                        L1 = 28;
                        L2 = 21;
                    }
                    if (d >= 9.5 && d < 11.8)
                    {
                        a1 = 7;
                        L1 = 32;
                        L2 = 23.5;
                    }
                    if (d >= 11.8 && d < 15)
                    {
                        a1 = 89;
                        L1 = 35;
                        L2 = 25;
                    }
                    if (d >= 15 && d < 19)
                    {
                        a1 = 11;
                        L1 = 40;
                        L2 = 25;
                    }
                    if (d >= 19 && d < 23.6)
                    {
                        a1 = 13.6;
                        L1 = 45;
                        L2 = 31;
                    }
                    if (d >= 23.6 && d <= 30)
                    {
                        a1 = 17.5;
                        L1 = 50;
                        L2 = 33;
                    }
                     double L3 = (db - ds) / tg;
                    //坐标
                    Vector2 v1 = new Vector2(0, 0);
                    Vector2 v2 = new Vector2(v1.X + l+L-L2 + 4, v1.Y);
                    Vector2 v29 = new Vector2(v1.X + 2, v1.Y);
                    Vector2 v3 = new Vector2(v29.X + d / 4.225, v29.Y + d / 2);
                    Vector2 v4 = new Vector2(v3.X, v3.Y - d);
                    Vector2 v5 = new Vector2(v29.X + l1 / 20.11538, v29.Y + d / 4.931);
                    Vector2 v6 = new Vector2(v29.X + l1 / 5.76838, v29.Y - d / 3.605);
                    Vector2 v8 = new Vector2(v29.X + l1 / 4.903125, v29.Y + d / 3.37795);
                    Vector2 v9 = new Vector2(v29.X + l1 / 3.0348, v29.Y - d / 4.98837);
                    Vector2 v10 = new Vector2(v29.X + l1 / 3.55782, v29.Y - d / 6.04225);
                    Vector2 v7 = new Vector2(v29.X + l1 / 2.96317, v29.Y - d / 2.715189);
                    Vector2 v11 = new Vector2(v29.X + l1 / 2.309, v29.Y - d / 2.5789);
                    Vector2 v12 = new Vector2(v29.X + l1 / 1.71194, v29.Y - d / 3.22556);
                    Vector2 v13 = new Vector2(v29.X + l1 / 2.9437, v29.Y + d / 1.9861);
                    Vector2 v14 = new Vector2(v29.X + l1 / 1.9216, v29.Y);
                    Vector2 v15 = new Vector2(v29.X + l1 / 1.23, v29.Y - d / 2.34426);
                    Vector2 v16 = new Vector2(v29.X + l1 / 2.0128, v29.Y + d / 1.9769);
                    Vector2 v17 = new Vector2(v29.X + l1 / 1.521, v29.Y);
                    Vector2 v18 = new Vector2(v29.X + l1 / 1.62759, v29.Y + d / 2.7857);
                    Vector2 v19 = new Vector2(v29.X + l1 / 1.4309, v29.Y);
                    Vector2 v20 = new Vector2(v29.X + l1 / 1.1369, v29.Y - d / 1.9678899);
                    Vector2 v21 = new Vector2(v29.X + l1 / 1.416, v29.Y + d / 2.0856);
                    Vector2 v22 = new Vector2(v29.X + l1 / 1.164378, v29.Y - d / 26.8125);
                    Vector2 v23 = new Vector2(v29.X + l1 / 1.19588, v29.Y - d / 2.13432);
                    Vector2 v24 = new Vector2(v29.X + l1 / 1.303697, v29.Y + d / 2.052631);
                    Vector2 v25 = new Vector2(v29.X + l1 / 1.113555, v29.Y + d / 12.25714);
                    Vector2 v26 = new Vector2(v25.X + l1 / 9.9625, v1.Y);
                    Vector2 v27 = new Vector2(v29.X + l1 / 1.0031969, v29.Y + d / 10.214285);
                    Vector2 v28 = new Vector2(v29.X + l1 / 1.205069, v29.Y + d / 2.033175);
                    Vector2 v30 = new Vector2(v29.X + l - L2, v28.Y);
                    Vector2 v31 = new Vector2(v30.X, v30.Y - (v28.Y - v20.Y) / 2 + db / 2);
                    Vector2 v32 = new Vector2(v31.X + L3, v30.Y - (v28.Y - v20.Y) / 2 + ds / 2);
                    Vector2 v33 = new Vector2(v32.X + (L - L3) / 2.59859, v30.Y - (v28.Y - v20.Y) / 2 + ds / 2.07619/2);
                    Vector2 v34 = new Vector2(v31.X + L - (L - L3) / 14.76, v33.Y);
                    Vector2 v35 = new Vector2(v34.X + (L - L3) / 14.76, v33.Y - (L - L3) / 14.76);
                    Vector2 v36 = new Vector2(v30.X, v30.Y - (v28.Y - v20.Y) / 2 + a1 / 2 / 3.246);
                    Vector2 v37 = new Vector2(v36.X + L2 / 1.0989, v36.Y);
                    Vector2 v38 = new Vector2(v36.X + L2, v30.Y - (v28.Y - v20.Y) / 2 + a1 / 2);
                    Vector2 v39 = new Vector2(v36.X + L1, v38.Y);
                    Vector2 v40 = new Vector2(v39.X, v37.Y);
                    Vector2 v41 = new Vector2(v36.X + L / 1.64729, v40.Y);
                    Vector2 v42 = new Vector2(v31.X, v31.Y - db);
                    Vector2 v43 = new Vector2(v32.X, v32.Y - ds);
                    Vector2 v44 = new Vector2(v33.X, v30.Y - (v28.Y - v20.Y) / 2 - ds / 2.07619/2);
                    Vector2 v45 = new Vector2(v34.X, v44.Y);
                    Vector2 v46 = new Vector2(v35.X, v45.Y + (L - L3) / 14.76);
                    Vector2 v47 = new Vector2(v36.X, v30.Y - (v28.Y - v20.Y) / 2 - a1 / 2 / 3.246);
                    Vector2 v48 = new Vector2(v37.X, v47.Y);
                    Vector2 v49 = new Vector2(v38.X, v38.Y - a1);
                    Vector2 v50 = new Vector2(v39.X, v49.Y);
                    Vector2 v51 = new Vector2(v40.X, v48.Y);
                    Vector2 v52 = new Vector2(v41.X, v51.Y);
                    Vector2 v53 = new Vector2(v30.X, v20.Y);
                    Vector2 v54 = new Vector2(v38.X, v30.Y);
                    Vector2 v55 = new Vector2(v38.X, v53.Y);
                    Vector2 v56 = new Vector2(v30.X + S, v31.Y + db / 4);
                    Vector2 v57 = new Vector2(v56.X, v42.Y - db / 4);

                    Line line1 = new Line(v1, v2);
                    line1.Layer = center;
                    line1.Linetype = Linetype.DashDot;
                    line1.LinetypeScale = 3;
                    dxf.AddEntity(line1);

                    LwPolyline line2 = new LwPolyline();
                    line2.Vertexes.Add(new LwPolylineVertex(v29));
                    line2.Vertexes.Add(new LwPolylineVertex(v5));
                    line2.Vertexes.Add(new LwPolylineVertex(v3));
                    line2.Vertexes.Add(new LwPolylineVertex(v29));
                    line2.Vertexes.Add(new LwPolylineVertex(v4));
                    line2.Vertexes.Add(new LwPolylineVertex(v6));
                    line2.Vertexes[0].Bulge = Math.Tan(-51 * pi / 180 / 4);
                    line2.Vertexes[4].Bulge = Math.Tan(43 * pi / 180 / 4);
                    fun.PolyFill(dxf, line2, 0.1, contour);

                    LwPolyline line3 = new LwPolyline();
                    line3.Vertexes.Add(new LwPolylineVertex(v3));
                    line3.Vertexes.Add(new LwPolylineVertex(v10));
                    line3.Vertexes[0].Bulge = Math.Tan(-32 * pi / 180 / 4);
                    fun.PolyFill(dxf, line3, 0.1, contour);

                    LwPolyline line4 = new LwPolyline();
                    line4.Vertexes.Add(new LwPolylineVertex(v17));
                    line4.Vertexes.Add(new LwPolylineVertex(v15));
                    line4.Vertexes[0].Bulge = Math.Tan(38 * pi / 180 / 4);
                    fun.PolyFill(dxf, line4, 0.1, contour);

                    LwPolyline line5 = new LwPolyline();
                    line5.Vertexes.Add(new LwPolylineVertex(v22));
                    line5.Vertexes.Add(new LwPolylineVertex(v23));
                    line5.Vertexes.Add(new LwPolylineVertex(v20));
                    line5.Vertexes[0].Bulge = Math.Tan(-47 * pi / 180 / 4);
                    line5.Vertexes[1].Bulge = Math.Tan(9 * pi / 180 / 4);
                    fun.PolyFill(dxf, line5, 0.1, contour);

                    LwPolyline line6 = new LwPolyline();
                    line6.Vertexes.Add(new LwPolylineVertex(v25));
                    line6.Vertexes.Add(new LwPolylineVertex(v26));
                    line6.Vertexes.Add(new LwPolylineVertex(v27));
                    line6.Vertexes[0].Bulge = Math.Tan(61 * pi / 180 / 4);
                    line6.Vertexes[1].Bulge = Math.Tan(61 * pi / 180 / 4);
                    fun.PolyFill(dxf, line6, 0.1, contour);

                    LwPolyline line7 = new LwPolyline();
                    line7.Vertexes.Add(new LwPolylineVertex(v20));
                    line7.Vertexes.Add(new LwPolylineVertex(v53));
                    fun.PolyFill(dxf, line7, 0.1, contour);

                    LwPolyline line8 = new LwPolyline();
                    line8.Vertexes.Add(new LwPolylineVertex(v30));
                    line8.Vertexes.Add(new LwPolylineVertex(v28));
                    fun.PolyFill(dxf, line8, 0.1, contour);

                    LwPolyline line9 = new LwPolyline();
                    line9.Vertexes.Add(new LwPolylineVertex(v31));
                    line9.Vertexes.Add(new LwPolylineVertex(v36));
                    line9.Vertexes.Add(new LwPolylineVertex(v37));
                    line9.Vertexes.Add(new LwPolylineVertex(v38));
                    line9.Vertexes.Add(new LwPolylineVertex(v39));
                    line9.Vertexes.Add(new LwPolylineVertex(v40));
                    line9.Vertexes.Add(new LwPolylineVertex(v41));
                    line9.Vertexes.Add(new LwPolylineVertex(v52));
                    line9.Vertexes.Add(new LwPolylineVertex(v51));
                    line9.Vertexes.Add(new LwPolylineVertex(v50));
                    line9.Vertexes.Add(new LwPolylineVertex(v49));
                    line9.Vertexes.Add(new LwPolylineVertex(v48));
                    line9.Vertexes.Add(new LwPolylineVertex(v47));
                    line9.Vertexes.Add(new LwPolylineVertex(v42));
                    line9.Vertexes.Add(new LwPolylineVertex(v43));
                    line9.Vertexes.Add(new LwPolylineVertex(v44));
                    line9.Vertexes.Add(new LwPolylineVertex(v45));
                    line9.Vertexes.Add(new LwPolylineVertex(v46));
                    line9.Vertexes.Add(new LwPolylineVertex(v35));
                    line9.Vertexes.Add(new LwPolylineVertex(v34));
                    line9.Vertexes.Add(new LwPolylineVertex(v33));
                    line9.Vertexes.Add(new LwPolylineVertex(v32));
                    line9.Vertexes.Add(new LwPolylineVertex(v31));
                    line9.Vertexes[2].Bulge = Math.Tan(-73 * pi / 180 / 4);
                    line9.Vertexes[6].Bulge = Math.Tan(-317 * pi / 180 / 4);
                    line9.Vertexes[10].Bulge = Math.Tan(-73 * pi / 180 / 4);
                    line9.Vertexes[14].Bulge = Math.Tan(-64 * pi / 180 / 4);
                    line9.Vertexes[20].Bulge = Math.Tan(-64 * pi / 180 / 4);
                    fun.PolyFill(dxf, line9, 0.1, contour);

                    Line line10 = new Line(v30, v54);
                    line10.Layer = refin;
                    line10.Linetype = Linetype.Dashed;
                    line10.LinetypeScale = 3;
                    dxf.AddEntity(line10);

                    Line line11 = new Line(v54, v38);
                    line11.Layer = refin;
                    line11.Linetype = Linetype.Dashed;
                    line11.LinetypeScale = 3;
                    dxf.AddEntity(line11);

                    Line line12 = new Line(v53, v55);
                    line12.Layer = refin;
                    line12.Linetype = Linetype.Dashed;
                    line12.LinetypeScale = 3;
                    dxf.AddEntity(line12);

                    Line line13 = new Line(v55, v49);
                    line13.Layer = refin;
                    line13.Linetype = Linetype.Dashed;
                    line13.LinetypeScale = 3;
                    dxf.AddEntity(line13);

                    LwPolyline line14 = new LwPolyline();
                    line14.Vertexes.Add(new LwPolylineVertex(v33));
                    line14.Vertexes.Add(new LwPolylineVertex(v44));
                    line14.Vertexes.Add(new LwPolylineVertex(v45));
                    line14.Vertexes.Add(new LwPolylineVertex(v34));
                    fun.PolyFill(dxf, line14, 0.1, contour);

                    Line line15 = new Line(v56, v57);
                    line15.Layer = center;
                    line15.Linetype = Linetype.DashDot;
                    line15.LinetypeScale = 3;
                    dxf.AddEntity(line15);

                    Arc c1 = fun.DrawArc3(v5, v6, v7);
                    fun.drawBArc(dxf, c1, 0.1, contour);

                    Arc c2 = fun.DrawArc3(v10, v7, v11);
                    fun.drawBArc(dxf, c2, 0.1, contour);

                    Arc c3 = fun.DrawArc3(v9, v8, v3);
                    fun.drawBArc(dxf, c3, 0.1, contour);

                    Arc c4 = fun.DrawArc3(v14, v13, v8);
                    fun.drawBArc(dxf, c4, 0.1, contour);

                    Arc c5 = fun.DrawArc3(v9, v11, v12);
                    fun.drawBArc(dxf, c5, 0.1, contour);

                    Arc c6 = fun.DrawArc3(v14, v12, v15);
                    fun.drawBArc(dxf, c6, 0.1, contour);

                    Arc c7 = fun.DrawArc3(v17, v16, v13);
                    fun.drawBArc(dxf, c7, 0.1, contour);

                    Arc c8 = fun.DrawArc3(v19, v18, v16);
                    fun.drawBArc(dxf, c8, 0.1, contour);

                    Arc c9 = fun.DrawArc3(v19, v15, v23);
                    fun.drawBArc(dxf, c9, 0.1, contour);

                    Arc c10 = fun.DrawArc3(v22, v21, v18);
                    fun.drawBArc(dxf, c10, 0.1, contour);

                    Arc c11 = fun.DrawArc3(v25, v24, v21);
                    fun.drawBArc(dxf, c11, 0.1, contour);

                    Arc c12 = fun.DrawArc3(v27, v28, v24);
                    fun.drawBArc(dxf, c12, 0.1, contour);



                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;




                    fun.dimrot1(dxf, v3, v4, 90, d, 1, height, arrowsize, exline, "d=" + d/scale , "", "");

                    fun.dimrot1(dxf, v29, v26, 180, d * 3, 1, height, arrowsize, exline, "l1=" + l1/scale , "", "");

                    fun.dimrot1(dxf, v29, v55, 180, d * 5, 1, height, arrowsize, exline, "l=" + l/scale , "", "");
                    
                    fun.dimrot1(dxf, v31, v56, 0, d * 3, 1, height, arrowsize, exline, "S=" + S/scale , "", "");

                    fun.dimrot1(dxf, v42, v46, 180, d * 5, 1, height, arrowsize, exline, "L=" + L/scale , "", "");



                }
                if (a == 2)
                {
                    //坐标
                    Vector2 v1 = new Vector2(0, 0);
                    Vector2 v2 = new Vector2(v1.X + l + 4, v1.Y);
                    Vector2 v29 = new Vector2(v1.X + 2, v1.Y);
                    Vector2 v3 = new Vector2(v29.X + d / 4.225, v29.Y + d / 2);
                    Vector2 v4 = new Vector2(v3.X, v3.Y - d);
                    Vector2 v5 = new Vector2(v29.X + l1 / 20.11538, v29.Y + d / 4.931);
                    Vector2 v6 = new Vector2(v29.X + l1 / 5.76838, v29.Y - d / 3.605);
                    Vector2 v8 = new Vector2(v29.X + l1 / 4.903125, v29.Y + d / 3.37795);
                    Vector2 v9 = new Vector2(v29.X + l1 / 3.0348, v29.Y - d / 4.98837);
                    Vector2 v10 = new Vector2(v29.X + l1 / 3.55782, v29.Y - d / 6.04225);
                    Vector2 v7 = new Vector2(v29.X + l1 / 2.96317, v29.Y - d / 2.715189);
                    Vector2 v11 = new Vector2(v29.X + l1 / 2.309, v29.Y - d / 2.5789);
                    Vector2 v12 = new Vector2(v29.X + l1 / 1.71194, v29.Y - d / 3.22556);
                    Vector2 v13 = new Vector2(v29.X + l1 / 2.9437, v29.Y + d / 1.9861);
                    Vector2 v14 = new Vector2(v29.X + l1 / 1.9216, v29.Y);
                    Vector2 v15 = new Vector2(v29.X + l1 / 1.23, v29.Y - d / 2.34426);
                    Vector2 v16 = new Vector2(v29.X + l1 / 2.0128, v29.Y + d / 1.9769);
                    Vector2 v17 = new Vector2(v29.X + l1 / 1.521, v29.Y);
                    Vector2 v18 = new Vector2(v29.X + l1 / 1.62759, v29.Y + d / 2.7857);
                    Vector2 v19 = new Vector2(v29.X + l1 / 1.4309, v29.Y);
                    Vector2 v20 = new Vector2(v29.X + l1 / 1.1369, v29.Y - d / 1.9678899);
                    Vector2 v21 = new Vector2(v29.X + l1 / 1.416, v29.Y + d / 2.0856);
                    Vector2 v22 = new Vector2(v29.X + l1 / 1.164378, v29.Y - d / 26.8125);
                    Vector2 v23 = new Vector2(v29.X + l1 / 1.19588, v29.Y - d / 2.13432);
                    Vector2 v24 = new Vector2(v29.X + l1 / 1.303697, v29.Y + d / 2.052631);
                    Vector2 v25 = new Vector2(v29.X + l1 / 1.113555, v29.Y + d / 12.25714);
                    Vector2 v26 = new Vector2(v25.X + l1 / 9.9625, v1.Y);
                    Vector2 v27 = new Vector2(v29.X + l1 / 1.0031969, v29.Y + d / 10.214285);
                    Vector2 v28 = new Vector2(v29.X + l1 / 1.205069, v29.Y + d / 2.033175);
                    Vector2 v30 = new Vector2(v29.X + l - (v28.Y - v20.Y) / 5, v28.Y);
                    Vector2 v31 = new Vector2(v30.X + (v28.Y - v20.Y) / 5, v30.Y - (v28.Y - v20.Y) / 5);
                    Vector2 v33 = new Vector2(v30.X, v20.Y);
                    Vector2 v32 = new Vector2(v33.X + (v28.Y - v20.Y) / 5, v33.Y + (v28.Y - v20.Y) / 5);

                    Vector2 v34 = new Vector2(v2.X + d, v2.Y);
                    Vector2 v35 = new Vector2(v34.X - d / 2 - 2, v34.Y);
                    Vector2 v36 = new Vector2(v34.X + d / 2 + 2, v34.Y);
                    Vector2 v37 = new Vector2(v34.X, v34.Y + d / 2 + 2);
                    Vector2 v38 = new Vector2(v34.X, v34.Y - d / 2 - 2);
                    Vector2 v39 = fun.Polar(v34, -77 * pi / 180, v30.Y - v1.Y);
                    Vector2 v40 = fun.Polar(v34, 31 * pi / 180, v30.Y - v1.Y);
                    Vector2 v41 = new Vector2(v34.X, v34.Y + v30.Y - v1.Y);
                    Vector2 v42 = new Vector2(v39.X, v39.Y + d / 4.37);
                    Vector2 v43 = fun.Polar(v34, -79 * pi / 180, d / 2);
                    Vector2 v44 = fun.Polar(v34, 103 * pi / 180, v30.Y - v1.Y);
                    Vector2 v45 = fun.Polar(v34, -149 * pi / 180, v30.Y - v1.Y);
                    Vector2 v46 = new Vector2(v41.X, v41.Y * -1);
                    Vector2 v47 = new Vector2(v44.X, v44.Y - d / 4.37);
                    Vector2 v48 = fun.Polar(v34, 101 * pi / 180, d / 2);
                    Vector2 v49 = new Vector2(v34.X, v34.Y + d / 2);
                    Vector2 v50 = new Vector2(v34.X, v34.Y - d / 2);
                    //作图
                    Line line1 = new Line(v1, v2);
                    line1.Layer = center;
                    line1.Linetype = Linetype.DashDot;
                    line1.LinetypeScale = 3;
                    dxf.AddEntity(line1);

                    LwPolyline line2 = new LwPolyline();
                    line2.Vertexes.Add(new LwPolylineVertex(v29));
                    line2.Vertexes.Add(new LwPolylineVertex(v5));
                    line2.Vertexes.Add(new LwPolylineVertex(v3));
                    line2.Vertexes.Add(new LwPolylineVertex(v29));
                    line2.Vertexes.Add(new LwPolylineVertex(v4));
                    line2.Vertexes.Add(new LwPolylineVertex(v6));
                    line2.Vertexes[0].Bulge = Math.Tan(-51 * pi / 180 / 4);
                    line2.Vertexes[4].Bulge = Math.Tan(43 * pi / 180 / 4);
                    fun.PolyFill(dxf, line2, 0.1, contour);

                    LwPolyline line3 = new LwPolyline();
                    line3.Vertexes.Add(new LwPolylineVertex(v3));
                    line3.Vertexes.Add(new LwPolylineVertex(v10));
                    line3.Vertexes[0].Bulge = Math.Tan(-32 * pi / 180 / 4);
                    fun.PolyFill(dxf, line3, 0.1, contour);

                    LwPolyline line4 = new LwPolyline();
                    line4.Vertexes.Add(new LwPolylineVertex(v17));
                    line4.Vertexes.Add(new LwPolylineVertex(v15));
                    line4.Vertexes[0].Bulge = Math.Tan(38 * pi / 180 / 4);
                    fun.PolyFill(dxf, line4, 0.1, contour);

                    LwPolyline line5 = new LwPolyline();
                    line5.Vertexes.Add(new LwPolylineVertex(v22));
                    line5.Vertexes.Add(new LwPolylineVertex(v23));
                    line5.Vertexes.Add(new LwPolylineVertex(v20));
                    line5.Vertexes[0].Bulge = Math.Tan(-47 * pi / 180 / 4);
                    line5.Vertexes[1].Bulge = Math.Tan(9 * pi / 180 / 4);
                    fun.PolyFill(dxf, line5, 0.1, contour);

                    LwPolyline line6 = new LwPolyline();
                    line6.Vertexes.Add(new LwPolylineVertex(v25));
                    line6.Vertexes.Add(new LwPolylineVertex(v26));
                    line6.Vertexes.Add(new LwPolylineVertex(v27));
                    line6.Vertexes[0].Bulge = Math.Tan(61 * pi / 180 / 4);
                    line6.Vertexes[1].Bulge = Math.Tan(61 * pi / 180 / 4);
                    fun.PolyFill(dxf, line6, 0.1, contour);

                    LwPolyline line7 = new LwPolyline();
                    line7.Vertexes.Add(new LwPolylineVertex(v20));
                    line7.Vertexes.Add(new LwPolylineVertex(v33));
                    line7.Vertexes.Add(new LwPolylineVertex(v30));
                    line7.Vertexes.Add(new LwPolylineVertex(v28));
                    fun.PolyFill(dxf, line7, 0.1, contour);

                    LwPolyline line8 = new LwPolyline();
                    line8.Vertexes.Add(new LwPolylineVertex(v30));
                    line8.Vertexes.Add(new LwPolylineVertex(v31));
                    line8.Vertexes.Add(new LwPolylineVertex(v32));
                    line8.Vertexes.Add(new LwPolylineVertex(v33));
                    fun.PolyFill(dxf, line8, 0.1, contour);

                    Arc c1 = fun.DrawArc3(v5, v6, v7);
                    fun.drawBArc(dxf, c1, 0.1, contour);

                    Arc c2 = fun.DrawArc3(v10, v7, v11);
                    fun.drawBArc(dxf, c2, 0.1, contour);

                    Arc c3 = fun.DrawArc3(v9, v8, v3);
                    fun.drawBArc(dxf, c3, 0.1, contour);

                    Arc c4 = fun.DrawArc3(v14, v13, v8);
                    fun.drawBArc(dxf, c4, 0.1, contour);

                    Arc c5 = fun.DrawArc3(v9, v11, v12);
                    fun.drawBArc(dxf, c5, 0.1, contour);

                    Arc c6 = fun.DrawArc3(v14, v12, v15);
                    fun.drawBArc(dxf, c6, 0.1, contour);

                    Arc c7 = fun.DrawArc3(v17, v16, v13);
                    fun.drawBArc(dxf, c7, 0.1, contour);

                    Arc c8 = fun.DrawArc3(v19, v18, v16);
                    fun.drawBArc(dxf, c8, 0.1, contour);

                    Arc c9 = fun.DrawArc3(v19, v15, v23);
                    fun.drawBArc(dxf, c9, 0.1, contour);

                    Arc c10 = fun.DrawArc3(v22, v21, v18);
                    fun.drawBArc(dxf, c10, 0.1, contour);

                    Arc c11 = fun.DrawArc3(v25, v24, v21);
                    fun.drawBArc(dxf, c11, 0.1, contour);

                    Arc c12 = fun.DrawArc3(v27, v28, v24);
                    fun.drawBArc(dxf, c12, 0.1, contour);

                    //2
                    Line line9 = new Line(v35, v36);
                    line9.Layer = center;
                    line9.Linetype = Linetype.DashDot;
                    line9.LinetypeScale = 3;
                    dxf.AddEntity(line9);

                    Line line10 = new Line(v37, v38);
                    line10.Layer = center;
                    line10.Linetype = Linetype.DashDot;
                    line10.LinetypeScale = 3;
                    dxf.AddEntity(line10);

                    LwPolyline line11 = new LwPolyline();
                    line11.Vertexes.Add(new LwPolylineVertex(v40));
                    line11.Vertexes.Add(new LwPolylineVertex(v42));
                    line11.Vertexes.Add(new LwPolylineVertex(v39));
                    line11.Vertexes.Add(new LwPolylineVertex(v43));
                    line11.Vertexes[0].Bulge = Math.Tan(50 * pi / 180 / 4);
                    fun.PolyFill(dxf, line11, 0.1, contour);

                    LwPolyline line12 = new LwPolyline();
                    line12.Vertexes.Add(new LwPolylineVertex(v45));
                    line12.Vertexes.Add(new LwPolylineVertex(v47));
                    line12.Vertexes.Add(new LwPolylineVertex(v44));
                    line12.Vertexes.Add(new LwPolylineVertex(v48));
                    line12.Vertexes[0].Bulge = Math.Tan(50 * pi / 180 / 4);
                    fun.PolyFill(dxf, line12, 0.1, contour);

                    LwPolyline line13 = new LwPolyline();
                    line13.Vertexes.Add(new LwPolylineVertex(v42));
                    line13.Vertexes.Add(new LwPolylineVertex(v47));
                    line13.Vertexes[0].Bulge = Math.Tan(19 * pi / 180 / 4);
                    fun.PolyFill(dxf, line13, 0.1, contour);

                    LwPolyline line14 = new LwPolyline();
                    line14.Vertexes.Add(new LwPolylineVertex(v49));
                    line14.Vertexes.Add(new LwPolylineVertex(v41));
                    fun.PolyFill(dxf, line14, 0.1, contour);

                    LwPolyline line15 = new LwPolyline();
                    line15.Vertexes.Add(new LwPolylineVertex(v46));
                    line15.Vertexes.Add(new LwPolylineVertex(v50));
                    fun.PolyFill(dxf, line15, 0.1, contour);

                    Arc c13 = fun.DrawArc3(v44, v45, v46);
                    fun.drawBArc(dxf, c13, 0.1, contour);

                    Arc c14 = fun.DrawArc3(v39, v40, v41);
                    fun.drawBArc(dxf, c14, 0.1, contour);

                    fun.drawcircle(dxf, v34, d / 2, 0.1, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;




                    fun.dimrot1(dxf, v3, v4, 90, 10, 1, height, arrowsize, exline, "d=" + d/scale , "", "");

                    fun.dimrot1(dxf, v29, v26, 180, d/2+10, 1, height, arrowsize, exline, "l1=" + l1/scale , "", "");

                    fun.dimrot1(dxf, v29, v32, 180, d/2+20, 1, height, arrowsize, exline, "l=" + l/scale , "", "");



                }






            }

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            Vector2 p0 = new Vector2(0, 0);


            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            //定义格式，路径导出


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);


        //}

    }
}
}